package com.medical.medical.service;

import com.medical.medical.entity.Department;
import com.medical.medical.mapper.DepartmentMapper;
import com.medical.medical.mapper.HospitalMapper;
import com.medical.medical.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.mapping.ResultMap;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName DepartmentServiceImpl
 * @Description 科室-接口实现类
 * @Author WLD
 * @Date 2022/9/14 8:56
 * @Version 1.0
 */
@Service
@Slf4j
public class DepartmentServiceImpl implements DepartmentService{

    @Resource
    private DepartmentMapper departmentMapper;

    @Override
     /**
      *@author WangLuDong
      *@Description 方法描述 查询所有科室
      *@Date 2022-09-14 18:01:13
      *@Return {@link List< Department>}
      */
    public List<Department> getDepartmentList() {
        return departmentMapper.getDepartmentList();
    }

    @Override
     /**
      *@author WangLuDong
      *@Description 方法描述 根据科室名获取科室
      *@Date 2022-09-16 09:41:03
       * @param kname
      *@Return {@link Department}
      */
    public Department getDepartmentIdByKname(String kname) {
        return null;
    }

    @Override
    public boolean addDepartment(Department department) {
        try {
            log.info("进入添加科室");
            return departmentMapper.addDepartment(department) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("程序异常");
        }
        return false;
    }

    @Override
    public boolean deleteDepartment(int departmentId) {
        try {
            return departmentMapper.deleteDepartment(departmentId) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("程序异常");
        }
        return false;
    }

}
